import request from '@/utils/request'

export function getAllRole(query) {
  return request({
    url: '/api/role/',
    method: 'get',
    params: query
  })
}

// 获取下拉框选择数据
export function getRoleSelectList(query) {
  return request({
    url: '/api/role/select/',
    method: 'get',
    params: query
  })
}

export function updateRole(id, data) {
  return request({
    url: '/api/role/' + id + '/',
    method: 'patch',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

export function createRole(data) {
  return request({
    url: '/api/role/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

export function deleteRole(id) {
  return request({
    url: '/api/role/' + id + '/',
    method: 'delete'
  })
}

export function setRolePerson(id, data) {
  return request({
    url: '/api/role/' + id + '/set_role_person/',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data: data
  })
}

export function getPermissionTree(query) {
  return request({
    url: '/api/permission/',
    method: 'get',
    params: query
  })
}
